
// This file will include all the files required.
// Always place this file last.
// If inside web page, loads files by adding a <script> to <head> for each file.
// Otherwise, loads files by calling require(filename); you need to provide this function yourself.

if (typeof Alkaline == 'undefined')
	var Alkaline = { Modules: {}, Processing: {} };

Alkaline.bootstrap = function(globalObject, dir) {
	Alkaline.Global = globalObject;
	
	if (!dir)
		dir = '';
	else if (dir.charAt(dir.length-1) != '/')
		dir += '/';
	
	for (var i = 0; i < Alkaline.bootstrap.required.length; i++) {
		var path = Alkaline.bootstrap.required[i].path.split('.');
		var obj = globalObject[path[0]];
		var j = 1;
		while (obj && j < path.length)
			obj = obj[path[j++]];
		if (!obj || j < path.length)
			Alkaline.bootstrap.load(dir + Alkaline.bootstrap.required[i].filename);
	}
}

Alkaline.bootstrap.load = function(filename) {
	if (typeof document != 'undefined' && document.createElement && document.documentElement && document.documentElement.firstChild) {
		var script = document.createElement('script');
		script.src = filename;
		document.documentElement.firstChild.appendChild(script);
		return;
	}
	require(filename);
}

Alkaline.bootstrap.required = [{
	filename: 'antlr3-all.js',
	path: 'org.antlr'
}, {
	filename: 'AlkalineLexer.js',
	path: 'AlkalineLexer'
}, {
	filename: 'AlkalineParser.js',
	path: 'AlkalineParser'
}, {
	filename: 'Alkaline.js',
	path: 'Alkaline.run'
}, {
	filename: 'Alkaline.JSInfo.js',
	path: 'Alkaline.JSInfo'
}, {
	filename: 'ProcessingState.js',
	path: 'Alkaline.Processing.ProcessingState'
}, {
	filename: 'LexicalContext.js',
	path: 'Alkaline.Processing.LexicalContext'
}, {
	filename: 'VariableDefinition.js',
	path: 'Alkaline.Processing.VariableDefinition'
}, {
	filename: 'ReferencedValue.js',
	path: 'Alkaline.Processing.ReferencedValue'
}, {
	filename: 'FunctionInstance.js',
	path: 'Alkaline.Processing.FunctionInstance'
}, {
	filename: 'ValueNull.js',
	path: 'Alkaline.Processing.ValueNull'
}, {
	filename: 'ValueUndefined.js',
	path: 'Alkaline.Processing.ValueUndefined'
}, {
	filename: 'PropertyDescriptor.js',
	path: 'Alkaline.Processing.PropertyDescriptor'
}, {
	filename: 'Operation.js',
	path: 'Alkaline.Processing.Operation'
}, {
	filename: 'Condition.js',
	path: 'Alkaline.Processing.Condition'
}, {
	filename: 'ValueDistribution.js',
	path: 'Alkaline.Processing.ValueDistribution'
}, {
	filename: 'ValueRegExp.js',
	path: 'Alkaline.Processing.ValueRegExp'
}, {
	filename: 'Alkaline.InputSource.js',
	path: 'Alkaline.InputSource'
}, {
	filename: 'Alkaline.CompileResult.js',
	path: 'Alkaline.CompileResult'
}, {
	filename: 'Alkaline.Runtime.js',
	path: 'Alkaline.Runtime'
}, {
	filename: 'Generator.js',
	path: 'Alkaline.Runtime.Generator'
}, {
	filename: 'XML.js',
	path: 'Alkaline.Runtime.XML'
}, {
	filename: 'AlkalineExtra.js',
	path: 'String.prototype.equals'
}, {
	filename: 'Alkaline.Module.js',
	path: 'Alkaline.Module'
}, {
	filename: 'Alkaline.TreeBuilder.js',
	path: 'Alkaline.TreeBuilder'
}, {
	filename: 'analyzer.js',
	path: 'Alkaline.Modules.Analyzer'
}, {
	filename: '5to3.js',
	path: 'Alkaline.Modules.5to3'
}, {
	filename: 'optimize.js',
	path: 'Alkaline.Modules.Optimize'
}, {
	filename: 'minify.js',
	path: 'Alkaline.Modules.Minify'
}, {
	filename: 'printer.js',
	path: 'Alkaline.Modules.Printer'
}, {
	filename: 'documentation.js',
	path: 'Alkaline.Modules.Documentation'
}, {
	filename: 'jsdoc.js',
	path: 'Alkaline.Modules.JSDoc'
}];
